*****************************************************
*Figure 1: Robot adoption at the CZ level, 1993-2007*
*****************************************************

return clear
capture project, doinfo
if (_rc==0 & !mi(r(pname))) global root `r(pdir)'  // run using -project-
else {  // running directly

	global root "$raw_data_geo/geo_cz1990_creation"

	cap program drop project
	program define project
		di "Project is disabled, skipping project command. (To re-enable, run -{stata program drop project}-)"
	end
	
}

* Specify subdirectories
global raw "$root/raw_data/cz1990"
global out "$root/geo_templates/cz1990"
global test "$root/tests/cz1990"
* Add utility programs to path
adopath ++ "$root/util"
*State lines
project, original("$root/geo_templates/state/state_coords_clean.dta") preserve
copy "$root/geo_templates/state/state_coords_clean.dta" "$out/state_coords_clean.dta", replace

use "$final_data_automation/czones_ExposureAutomationLong.dta", clear

rename czone cz
merge n:1 cz using "$out/cz1990_database.dta", keep(3) nogenerate

su expof_us_adj93_07

maptile expof_euro7_qo93_07, conus geo(cz1990) stateoutline(medium) geofolder($out) rangecolor(ebblue*.01 ebblue*2) ///
		cutvalues(0.5 0.75 1 1.25 1.5 1.75 2 2.25)   ///
		twopt(title("", size(medium)) legend(position(5) ring(0) size(medium) symysize(*.5) symxsize(*.5) order(10 "{&ge}2.25" 9 "2.00-2.24" 8 "1.75-1.99"  7 "1.50-1.74"  6 "1.25-1.49" 5 "1.00-1.24" 4 "0.75-0.99" 3 "0.50-0.74" 2 "{&le}0.49")) name(exposure_to_robots, replace)) 
graph export "$figures_main/Figure 1.png", replace

*Mean and standard deviation inserted manually
su expof_us_adj93_07
